#!/usr/bin/env python3
import re

uids = []
pt = re.compile(r':x:(\d{3}):')

f = open('passwd')
for i in f:
    uid_match = pt.search(i)
    if uid_match is not None:
        uids.append(uid_match.group(1))

f.close()
print(uids)
